﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace MesShell.Utils
{
    internal class HttpUtils
    {

        public static async Task<string> Post(string url, string jsonData, string site,string token = "")
        {

            using (var client = new HttpClient())
            {   
                client.DefaultRequestHeaders.Add("SrcSite", site);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                
                // Console.WriteLine(jsonData);

                HttpContent content = new StringContent(jsonData, Encoding.UTF8, "application/json");
                HttpResponseMessage response = await client.PostAsync(url, content);
                string result = await response.Content.ReadAsStringAsync();
                return result;
            }

        }

    }
}
